﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

using Hangjing.Model;
using Hangjing.SQLServerDAL;
using Hangjing.Common;

/// <summary>
/// 获取用户地址
/// </summary>
public partial class AndroidAPI_shop_userAddressesByTell : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();

        Custorder dal = new Custorder();

        int pagesize = HjNetHelper.GetPostParam("pagesize", 8);
        int pageindex = HjNetHelper.GetPostParam("pageindex", 1);
        int pagecount = 1;

        //string did = WebUtility.InputText(Request["did"]);//商家编号
        string tel = WebUtility.InputText(Request["tel"]).Replace("-", "");


        StringBuilder orderlistjson = new StringBuilder();
        string SqlWhere = "  EXISTS (SELECT DataID FROM dbo.ECustomer WHERE DataID = dbo.EAddress.UserID AND (Name = '" + tel + "' or Tell ='" + tel + "') ) and  Lat <> ''";

        orderlistjson.Append("{\"page\":\"" + pageindex.ToString() + "\",\"total\":\"" + pagecount + "\", \"orderlist\":[");

        EAddressInfo info = new EAddressInfo();

        IList<EAddressInfo> list = new EAddress().GetList(pagesize, 1, SqlWhere, "AddTime", 1);
        for (int i = 0; i < list.Count; i++)
        {
            info = new EAddressInfo();
            info = list[i];
            orderlistjson.Append("{\"orderid\":\"" + info.Lat + "\",\"shopname\":\"" + info.Lng + "\",\"addtime\":\"" + info.AddTime.ToString("yyyy-MM-dd HH:mm:dd") + "\",\"totalmoney\":\"" + info.Receiver + "\",\"state\":\"" + info.DataID + "\",\"address\":\"" + info.Address + "\"");
            orderlistjson.Append(",\"PayMode\":\"" + 0 + "\"");
            orderlistjson.Append(",\"paystate\":\"" +0 + "\"");
            orderlistjson.Append(",\"sendstate\":\"" + 0 + "\"");
            orderlistjson.Append(",\"eattype\":\"" + 0 + "\"");
            orderlistjson.Append(",\"IsShopSet\":\"" +0 + "\"");
            orderlistjson.Append(",\"people\":\"" + 0 + "\"");

            orderlistjson.Append(",\"SystemUserId\":\"" + 0 + "\"");


            orderlistjson.Append(",\"sendmoney\":\"" + 0 + "\"");
            orderlistjson.Append("},");
        }

        orderlistjson.Append("]}");

        Response.Write(orderlistjson.ToString().Replace("},]}", "}]}"));
        Response.End();

    }
}
